home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Http Server / •OT_Classes / TAddrInet.h < prev    next >
Encoding:
Text File  |  1996-01-11  |  2.3 KB  |  85 lines  |  [TEXT/CWIE]

  1. //    TAddrInet.h - Macintosh OpenTransport network "address family independent" class object
  2. // 
  3. // Apple Macintosh Developer Technical Support
  4. // Written by:  Vinne Moscaritolo
  5. //
  6. //  Copyright (work in progress)  Apple Computer, Inc All rights reserved.
  7. //
  8. // You may incorporate this sample code into your applications without
  9. // restriction, though the sample code has been provided "AS IS" and the
  10. // responsibility for its operation is 100% yours.  However, what you are
  11. // not permitted to do is to redistribute the source as "DSC Sample Code"
  12. // after having made changes. If you're going to re-distribute the source,
  13. // we require that you make it clear in the source that the code was
  14. // descended from Apple Sample Code, but that you've made changes.
  15. // 
  16.  
  17. #ifndef _H_TAddrInet
  18. #define _H_TAddrInet
  19.  
  20. #include <OpenTptInternet.h>   
  21. #include "TAddr.h"
  22.  
  23. //
  24. // TAddrInet.h - "address family independent" class object
  25. //
  26. class TAddrInet : public TAddr
  27. {
  28.  
  29. public:
  30. //     CONSTRUCTORS AND DESTRUCTORS
  31.  
  32.     TAddrInet()    {
  33.              fAddress.fAddressType  = AF_INET;
  34.              fAddress.fPort         = 0;
  35.              fAddress.fHost          = kOTAnyInetAddress;
  36.              };
  37.              
  38.     TAddrInet(InetPort thePort) {
  39.              fAddress.fAddressType  = AF_INET;
  40.              fAddress.fPort         = thePort;
  41.              fAddress.fHost          = kOTAnyInetAddress;
  42.              };
  43.  
  44.     TAddrInet(InetHost theHost, InetPort thePort){
  45.              fAddress.fAddressType  = AF_INET;
  46.              fAddress.fPort         = thePort;
  47.              fAddress.fHost          = theHost;
  48.              };
  49.  
  50.     TAddrInet(TNetbuf *theBuf) {
  51.             InetAddress* data = (InetAddress*) theBuf->buf;
  52.             fAddress = *data;
  53.             };
  54.  
  55. public:
  56. // ACCESSORS 
  57.   size_t             GetMaxSize (void) const { return sizeof(InetAddress); }
  58.   size_t             GetSize (void) const { return sizeof(InetAddress); }
  59.   OTAddressType     GetType (void) const { return AF_INET; };
  60.   OTAddress*        GetAddr (void) const { return (OTAddress*) &fAddress; };
  61.   
  62. // Equality/inequality tests
  63.      friend Boolean operator== (const TAddrInet& a1, const TAddrInet& a2);
  64.      friend Boolean operator!= (const TAddrInet& a1, const TAddrInet& a2);
  65.  
  66. // Assignment
  67.     TAddrInet& operator= ( const TAddrInet& a);
  68. //    TAddrInet& operator= ( const TNetbuf& n);
  69.  
  70. // Stream functions
  71.     friend ostream &operator<< (ostream& s, const TAddrInet& a);
  72.     friend istream &operator>> (istream& s, TAddrInet& a);
  73.  
  74. //  High Level functions
  75.     virtual TAddr*    Clone();
  76.  
  77. // PRIVATE FIELDS
  78. protected:
  79.     InetAddress    fAddress;
  80. };
  81.  
  82.  
  83. #endif
  84.  
  85.